package org.learn.intermediate.com.exercise;

public class StringBufferExercise {
    public static void main(String[] args) {
        String price = "1234567.56";
        StringBuffer sb = new StringBuffer(price);

        //循环加逗号
        for (int i = sb.lastIndexOf(".")-3; i > 0; i -= 3) {
            sb = sb.insert(i,',');
        }
        //
        System.out.println(sb);
    }
}
